package com.tekj.cxqcb.view.Module.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tekj.cxqcb.R;
import com.tekj.cxqcb.view.Module.bean.ScreenBean;

import java.util.List;

/**
 * 筛选下使用的adapter
 */
public class Screen3Adapter extends BaseQuickAdapter<ScreenBean, BaseViewHolder> {

    private int checkItemPosition = -1;

    public void setCheckItem(int position) {
        checkItemPosition = position;
        notifyDataSetChanged();
    }

    public int getCheckItemPosition() {
        return checkItemPosition;
    }

    public Screen3Adapter(@Nullable List<ScreenBean> data) {
        super(R.layout.item_default_drop_down, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ScreenBean item) {
        helper.setText(R.id.text, item.getName());
        helper.setTextColor(R.id.text, mContext.getResources().getColor(
                checkItemPosition == helper.getLayoutPosition() ? R.color.drop_down_selected : R.color.drop_down_unselected));
        helper.setBackgroundColor(R.id.text, mContext.getResources().getColor(
                checkItemPosition == helper.getLayoutPosition() ?
                        R.color.check_bg : R.color.white));
    }
}
